// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

// Tests size limits on MakeMoveVec

//# init --addresses test=0x0 --accounts A --protocol-version 81

//# programmable --inputs 0u64
//> 0: MakeMoveVec<u64>([Input(0), Input(0), Input(0), Input(0), Input(0), Input(0), Input(0), Input(0)]);
//> 1: MakeMoveVec<vector<u64>>([Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0)]);
//> 2: MakeMoveVec<vector<vector<u64>>>([Result(1), Result(1), Result(1), Result(1), Result(1), Result(1), Result(1), Result(1)]);
//> 3: MakeMoveVec<vector<vector<vector<u64>>>>([Result(2), Result(2), Result(2), Result(2), Result(2), Result(2), Result(2), Result(2)]);
//> 4: MakeMoveVec<vector<vector<vector<vector<u64>>>>>([Result(3), Result(3), Result(3), Result(3), Result(3), Result(3), Result(3), Result(3)]);
//> 5: MakeMoveVec<vector<vector<vector<vector<vector<u64>>>>>>([Result(4), Result(4), Result(4), Result(4), Result(4), Result(4), Result(4), Result(4)]);

//# publish

module test::m;

public struct Data has copy, drop, store {
    f: vector<u8>,
}

public struct Obj has key {
    id: UID,
    data: Data,
}

public fun data(): Data {
    Data { f: vector::tabulate!(1024, |_| 0) }
}

public fun obj(ctx: &mut TxContext): Obj {
  Obj { id: object::new(ctx), data: data() }
}

public fun objs(
    ctx: &mut TxContext,
): (Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj, Obj) {
    (obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx),obj(ctx))
}

public fun delete_objs(objs: vector<Obj>) {
    objs.do!(|Obj { id, .. } | object::delete(id))
}

//# programmable
//> 0: test::m::data();
//> 1: MakeMoveVec<test::m::Data>([Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0), Result(0)]);

//# programmable
//> 0: test::m::objs();
//> 1: MakeMoveVec<test::m::Obj>([NestedResult(0,0), NestedResult(0,1), NestedResult(0,2), NestedResult(0,3), NestedResult(0,4), NestedResult(0,5), NestedResult(0,6), NestedResult(0,7), NestedResult(0,8), NestedResult(0,9), NestedResult(0,10), NestedResult(0,11), NestedResult(0,12), NestedResult(0,13), NestedResult(0,14), NestedResult(0,15), NestedResult(0,16), NestedResult(0,17), NestedResult(0,18), NestedResult(0,19), NestedResult(0,20), NestedResult(0,21), NestedResult(0,22), NestedResult(0,23), NestedResult(0,24), NestedResult(0,25), NestedResult(0,26), NestedResult(0,27), NestedResult(0,28), NestedResult(0,29), NestedResult(0,30), NestedResult(0,31), NestedResult(0,32), NestedResult(0,33), NestedResult(0,34), NestedResult(0,35), NestedResult(0,36), NestedResult(0,37), NestedResult(0,38), NestedResult(0,39), NestedResult(0,40), NestedResult(0,41), NestedResult(0,42), NestedResult(0,43), NestedResult(0,44), NestedResult(0,45), NestedResult(0,46), NestedResult(0,47), NestedResult(0,48), NestedResult(0,49), NestedResult(0,50), NestedResult(0,51), NestedResult(0,52), NestedResult(0,53), NestedResult(0,54), NestedResult(0,55), NestedResult(0,56), NestedResult(0,57), NestedResult(0,58), NestedResult(0,59), NestedResult(0,60), NestedResult(0,61), NestedResult(0,62), NestedResult(0,63), NestedResult(0,64), NestedResult(0,65), NestedResult(0,66), NestedResult(0,67), NestedResult(0,68), NestedResult(0,69), NestedResult(0,70), NestedResult(0,71), NestedResult(0,72), NestedResult(0,73), NestedResult(0,74), NestedResult(0,75), NestedResult(0,76), NestedResult(0,77), NestedResult(0,78), NestedResult(0,79), NestedResult(0,80), NestedResult(0,81), NestedResult(0,82), NestedResult(0,83), NestedResult(0,84), NestedResult(0,85), NestedResult(0,86), NestedResult(0,87), NestedResult(0,88), NestedResult(0,89), NestedResult(0,90), NestedResult(0,91), NestedResult(0,92), NestedResult(0,93), NestedResult(0,94), NestedResult(0,95), NestedResult(0,96), NestedResult(0,97), NestedResult(0,98), NestedResult(0,99), NestedResult(0,100), NestedResult(0,101), NestedResult(0,102), NestedResult(0,103), NestedResult(0,104), NestedResult(0,105), NestedResult(0,106), NestedResult(0,107), NestedResult(0,108), NestedResult(0,109), NestedResult(0,110), NestedResult(0,111), NestedResult(0,112), NestedResult(0,113), NestedResult(0,114), NestedResult(0,115), NestedResult(0,116), NestedResult(0,117), NestedResult(0,118), NestedResult(0,119), NestedResult(0,120), NestedResult(0,121), NestedResult(0,122), NestedResult(0,123), NestedResult(0,124), NestedResult(0,125), NestedResult(0,126), NestedResult(0,127), NestedResult(0,128), NestedResult(0,129), NestedResult(0,130), NestedResult(0,131), NestedResult(0,132), NestedResult(0,133), NestedResult(0,134), NestedResult(0,135), NestedResult(0,136), NestedResult(0,137), NestedResult(0,138), NestedResult(0,139), NestedResult(0,140), NestedResult(0,141), NestedResult(0,142), NestedResult(0,143), NestedResult(0,144), NestedResult(0,145), NestedResult(0,146), NestedResult(0,147), NestedResult(0,148), NestedResult(0,149), NestedResult(0,150), NestedResult(0,151), NestedResult(0,152), NestedResult(0,153), NestedResult(0,154), NestedResult(0,155), NestedResult(0,156), NestedResult(0,157), NestedResult(0,158), NestedResult(0,159), NestedResult(0,160), NestedResult(0,161), NestedResult(0,162), NestedResult(0,163), NestedResult(0,164), NestedResult(0,165), NestedResult(0,166), NestedResult(0,167), NestedResult(0,168), NestedResult(0,169), NestedResult(0,170), NestedResult(0,171), NestedResult(0,172), NestedResult(0,173), NestedResult(0,174), NestedResult(0,175), NestedResult(0,176), NestedResult(0,177), NestedResult(0,178), NestedResult(0,179), NestedResult(0,180), NestedResult(0,181), NestedResult(0,182), NestedResult(0,183), NestedResult(0,184), NestedResult(0,185), NestedResult(0,186), NestedResult(0,187), NestedResult(0,188), NestedResult(0,189), NestedResult(0,190), NestedResult(0,191), NestedResult(0,192), NestedResult(0,193), NestedResult(0,194), NestedResult(0,195), NestedResult(0,196), NestedResult(0,197), NestedResult(0,198), NestedResult(0,199), NestedResult(0,200), NestedResult(0,201), NestedResult(0,202), NestedResult(0,203), NestedResult(0,204), NestedResult(0,205), NestedResult(0,206), NestedResult(0,207), NestedResult(0,208), NestedResult(0,209), NestedResult(0,210), NestedResult(0,211), NestedResult(0,212), NestedResult(0,213), NestedResult(0,214), NestedResult(0,215), NestedResult(0,216), NestedResult(0,217), NestedResult(0,218), NestedResult(0,219), NestedResult(0,220), NestedResult(0,221), NestedResult(0,222), NestedResult(0,223), NestedResult(0,224), NestedResult(0,225), NestedResult(0,226), NestedResult(0,227), NestedResult(0,228), NestedResult(0,229), NestedResult(0,230), NestedResult(0,231), NestedResult(0,232), NestedResult(0,233), NestedResult(0,234), NestedResult(0,235), NestedResult(0,236), NestedResult(0,237), NestedResult(0,238), NestedResult(0,239), NestedResult(0,240), NestedResult(0,241), NestedResult(0,242), NestedResult(0,243), NestedResult(0,244), NestedResult(0,245), NestedResult(0,246), NestedResult(0,247), NestedResult(0,248), NestedResult(0,249), NestedResult(0,250), NestedResult(0,251), NestedResult(0,252), NestedResult(0,253), NestedResult(0,254)]);
//> 2: test::m::delete_objs(Result(1));
